package by.bucha.testproject.app;

import by.bucha.testproject.R;
import by.bucha.testproject.fragments.FileExplorerFragment;
import by.bucha.testproject.fragments.ParsedXmlListFragment;
import by.bucha.testproject.fragments.PersonalListFragment;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTabHost;

public class MainTabActivity extends FragmentActivity {

	private FragmentTabHost mTabHost;

	public static final String TAG_PERSONAL_LIST = "it is list fragment";

	public static final String TAG_PARSED_XML = "it is parsed xml fragment";

	public static final String TAG_IMAGE_VIEW_PAGER = "it is image view pager fragment";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main_tab);

		getActionBar().setDisplayShowHomeEnabled(false);
		getActionBar().setDisplayShowTitleEnabled(false);

		mTabHost = (FragmentTabHost) findViewById(R.id.activity_main_tab_tab_host);
		mTabHost.setup(this, getSupportFragmentManager(),
				R.id.activity_main_tab_tab_content);

		String tabListIndicator = getResources()
				.getString(
						R.string.main_tab_activity_strings_people_list_tab_list_indicator);
		addTab(TAG_PERSONAL_LIST, tabListIndicator, PersonalListFragment.class,
				null);

		String tabXmlIndicator = getResources()
				.getString(
						R.string.main_tab_activity_strings_people_list_tab_xml_indicator);
		addTab(TAG_PARSED_XML, tabXmlIndicator, ParsedXmlListFragment.class,
				null);

		String tabImageIndicator = getResources()
				.getString(
						R.string.main_tab_activity_strings_people_list_tab_images_indicator);
		addTab(TAG_IMAGE_VIEW_PAGER, tabImageIndicator,
				FileExplorerFragment.class, null);
	}

	private void addTab(String tag, String indicator, Class<?> fragment,
			Bundle bundle) {
		mTabHost.addTab(mTabHost.newTabSpec(tag).setIndicator(indicator),
				fragment, bundle);
	}
}
